package com.dong.dao;

import com.dong.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IUserDao {
    @Select("select * from usertable")
    List<User> findAll();

    @Insert("insert into usertable (username,password,gender,email,birthDate) " +
            "values (#{username},#{password},#{gender},#{email},#{birthDate})")
    void saveUser(User user);

    @Update("update usertable set username=#{username},password=#{password} where id=#{id}")
    void updateUser(User user);

    @Delete("delete from usertable where id=#{id} ")
    void deleteUser(int id);

    @Select("select * from usertable where id=#{id}")
    User findById(int id);

    @Select("select * from usertable where username like concat('%',#{name},'%')")
    List<User> findByName(String username);

    @Select("select count(*) from usertable where id>#{id}")
    int findAllCount(int id);
}
